Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #36823 - Create job invocations detail page with main info #839

Merged
merged 1 commit into from
Nov 29, 2023

Conversation

kmalyjur
Copy link
Contributor

@kmalyjur kmalyjur commented Oct 11, 2023

The commit creates a new job invocation detail page (see discussion) which is experimental until finished - you can find it in Lab Features or see /experimental/job_invocations_detail/${JOB_ID}. It includes the main information.

image

Update: There is a link on the old detail page to the new one if the experimental labs setting is on.

image

import { selectAPIResponse } from 'foremanReact/redux/API/APISelectors';

export const selectItems = state =>
selectAPIResponse(state, 'JOB_INVOCATION_KEY') || [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since items is used as an object { description, status_label: statusLabel, task } = items;, the fallback should be an empty object {}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, selectAPIResponse already gives a fallback, so no fallback needed.
export const selectAPIResponse = (state, key) => selectAPIByKey(state, key).response || {};

@@ -232,6 +232,7 @@ class Engine < ::Rails::Engine
caption: N_('Job templates'),
parent: :hosts_menu,
after: :provisioning_templates

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra space :)

Comment on lines 24 to 25
const finished = statusLabel === 'failed' || statusLabel === 'succeeded';
const autoRefresh = task?.state === 'pending' || false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use constants for failed, succeeded, pending

Comment on lines 27 to 24
const getData = url =>
withInterval(
get({
key: JOB_INVOCATION_KEY,
url,
handleError: () => {
dispatch(stopInterval(JOB_INVOCATION_KEY));
},
}),
1000
);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move to an actions file

</DescriptionListDescription>
</DescriptionListGroup>
<DescriptionListGroup>
<DescriptionListTerm>{__('Run on:')}</DescriptionListTerm>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably should change the text according to if it already ran or if its going to run in the future, can be done in the next pr but would be nice to have some todo note

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

ssh_user: sshUser,
template_invocations: template,
} = data;
const effectiveUser = ssh ? ssh.effective_user : null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When setting an effective user on a job, I dont see its value in the job invocation

@kmalyjur kmalyjur force-pushed the job-inv-main branch 2 times, most recently from c07d707 to 6c1f9d2 Compare October 24, 2023 11:23
@kmalyjur
Copy link
Contributor Author

@MariaAga Thank you for your review, I've updated the code and changed how I retrieve "effective_user" and some other attributes.

@kmalyjur
Copy link
Contributor Author

Thanks to Adam's feedback, I've just deleted my unnecessary changes in the job_invocations_controller.rb.

import { selectAPIResponse } from 'foremanReact/redux/API/APISelectors';

export const selectItems = state =>
selectAPIResponse(state, 'JOB_INVOCATION_KEY');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JOB_INVOCATION_KEY should be from JobInvocationConstants

const dateConverted = new Date(startAt);
const dateLocaleFormatted = dateConverted
.toLocaleString(documentLocale(), dateOptions)
.replace(/(\d{4}) /, '$1, ');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why have this line? it adds a , after the year but in some locales it doesnt make sense to add.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to do exactly what you said, but I didn't realize it may be strange in other locales. I'll just delete it

Copy link
Member

@MariaAga MariaAga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM!
@adamruzicka Can you take a look at the ruby parts?

lib/foreman_remote_execution/engine.rb Outdated Show resolved Hide resolved
webpack/JobInvocationDetail/JobInvocationOverview.js Outdated Show resolved Hide resolved
lib/foreman_remote_execution/engine.rb Outdated Show resolved Hide resolved
app/views/api/v2/job_invocations/base.json.rabl Outdated Show resolved Hide resolved
@kmalyjur kmalyjur force-pushed the job-inv-main branch 2 times, most recently from 8de6792 to 8e6a585 Compare November 22, 2023 13:17
Copy link
Contributor

@adamruzicka adamruzicka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last nitpick, apart from it lgtm

app/views/api/v2/job_invocations/base.json.rabl Outdated Show resolved Hide resolved
Copy link
Contributor

@adamruzicka adamruzicka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@adamruzicka adamruzicka merged commit ea8a0d6 into theforeman:master Nov 29, 2023
5 checks passed
@adamruzicka
Copy link
Contributor

Thank you @kmalyjur & @MariaAga !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants